$(function(){
	
	yzm1 = new GVerify("v_container");
	//给登录按钮绑定单击事件
	
	$("#regist").click(registUser);
});
var yzm1;
function registUser() {
	var password=$("#password").val().trim();
	
	var f_password=$("#f_password").val().trim();
	var phone=$("#phone").val().trim();
	var yzm=$("#yzm").val().trim();
	$("#count_span").html("");
	$("#password_span").html("");
	$("#f_password_span").html("");
	$("#yzm_span").html("");
	//字母转换为小写
/*	yzm = yzm.toLowerCase();
	yzm1 = yzm1.toLowerCase();*/
	//字母转换为大写
	//yzm = yzm.toUpperCase()
//	alert(yzm1);
	
	var ok = true;
	if(phone==""){
		ok=false;
		
		$("#count_span").html("账号为空");
	}
	if(password==""){
		ok=false;
//		$("#warning_2").show();
		$("#password_span").html("新密码为空");
	}
		
	
	if(f_password==""){
		ok=false;
//		$("#warning_3").show();
		$("#f_password_span").html("确认密码为空");
	}else if(f_password!=password){
		ok=false;
//		$("#warning_3").show();
		$("#f_password_span").html("密码不一致");
	}
	if(yzm==""){
		ok=false;
		$("#yzm_span").html("验证码为空");
		
	}else if(yzm1.validate(yzm)){
		
	}else{
		ok=false;
		$("#yzm_span").html("验证码不一致");
		
	}
	
	if(ok){
		$.ajax({
			url:base_path+"/login/update.do",
			type:"post",
			data:{"phone":phone,"password":password},
		    dataType:"json",
		    success:function(result){
		    	if(result.status==0){
		    		alert(result.msg);
		    		window.location.href ="login.html";
		    		
		    	}else if(result.status==1){
		    		
					$("#count_span").html(result.msg);
		    	}
		    	
		    },
			error:function(){
		    		alert("修改异常");
		    	}
		});
		
	}
}